﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TuanHuy.BLL;
using TuanHuy.DAL.EntityClasses;
public partial class Admin_ListProduct : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            loadCatolery();
            loadGrid();
        }
    }


    protected void grTour_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Delete")
        {
            string id = e.CommandArgument.ToString();
            ProductsLanguageManager.CreateInstant().DeleteById(decimal.Parse(id));
            loadGrid();
        }
    }

    public void PendingRecordsGridview_RowDeleting(Object sender, GridViewDeleteEventArgs e)
    {

    }

    private void loadCatolery()
    {
        ddlCat.DataSource = CategoryManager.CreateInstant().SelectAllLST().ToList();
        ddlCat.DataTextField = "CategoryName";
        ddlCat.DataValueField = "CategoryId";
        ddlCat.DataBind();

    }

    private void loadGrid()
    {
        
        grTour.DataSource = ProductsLanguageManager.CreateInstant().SelectByCategoryIdLST(int.Parse(ddlCat.SelectedValue)).ToList();
        grTour.DataBind();
        //}
    }

    private void DeleteImage(string path)
    {
        //if (File.Exists(Server.MapPath(path)))
        //{
        //    File.Delete(Server.MapPath(path));

        //}
    }
    protected void ddlCat_SelectedIndexChanged(object sender, EventArgs e)
    {
        loadGrid();

    }
}